#!/bin/sh
# load-balance(N-WAN) Script VER 0.10a for openwrt  by QQ GROUP 120752328

. /etc/functions.sh

ps_pppoe_num=$(ps -w 2>&1 | grep -c 'pppoe.so')

config_wan_pppoe_num(){
local proto
local cfg="$1"

config_get proto "$cfg" proto

eval "echo $cfg|grep -q wan"

# if wan ifdown interface 
[ "$?" = 0  -a $proto = "pppoe" ] && {
		wan_num=`expr $wan_num + 1`
}

}



online_check(){
	local wan_num=0
	config_load network
	config_foreach config_wan_pppoe_num interface

[ "$ps_pppoe_num" -le "$wan_num" ]&& sh /lib/nwan/pppoeup;

}

online_check